package com.lzb.watermarkcamera.adapter;

import android.graphics.Color;
import android.view.View;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.watermarkcamera.R;
import com.lzb.watermarkcamera.basic.ProviderMultiAdapter;
import com.lzb.watermarkcamera.bean.ColorBean;


public class ColorAdapter extends ProviderMultiAdapter<ColorBean> {

    public ColorAdapter() {
        addItemProvider(new ColorProvider());
    }

    private class ColorProvider extends BaseItemProvider<ColorBean> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_color;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, ColorBean bean) {
            baseViewHolder.setBackgroundColor(R.id.llColorItem, Color.parseColor(bean.getColor()));
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.ivColorItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivColorItemSel).setVisibility(View.GONE);
            }
        }
    }

}
